import requests,unittest

class weidu(unittest.TestCase):

    host='http://10.59.9.18'
    doctorId=None
    sessionId=None
    #登录 login
    def test_01_login(self):
        url=weidu.host+'/health/doctor/v1/login'
        json={'email':'2306398720@qq.com','pwd':'lZjdXyj15cOhn1a0yJKsW7o+fw/ogBDzn6CcyPSJUVIMmCPtCs+zuPwh7IZkXZiRhJvvjdIz9D2z1jkMOtD/36ddaLFMtQd9xIk0jAaDP1TH/lEHvvUPwot6asMGMGkH9EgBPT+4eaYC77BGQBPOASweQZE5KDF8BeN/c0sLfSw='}
        login=requests.post(url=url,data=json)
        print(login.json())
        weidu.doctorId=login.json()['result']['doctorId']
        print(weidu.doctorId)
        weidu.sessionId=login.json()['result']['sessionId']
        print(weidu.sessionId)

    #历史问诊列表 InquiryRecord
    recordId=None
    userId=None
    def test_02_inquiry(self):
        url=weidu.host+'/health/doctor/inquiry/verify/v1/findHistoryInquiryRecord'
        headers={'doctorId':str(weidu.doctorId),'sessionId':weidu.sessionId}
        json={'page':1,'count':5}
        inquiry=requests.get(url=url,headers=headers,params=json)
        print(inquiry.json())
        weidu.recordId=inquiry.json()['result'][0]['recordId']
        print(weidu.recordId)
        weidu.userId=inquiry.json()['result'][0]['userId']
        print(weidu.userId)

    #问诊记录列表 RecordList
    def test_03_recordlist(self):
        url = weidu.host + '/health/doctor/inquiry/verify/v1/findInquiryRecordList'
        headers = {'doctorId': str(weidu.doctorId), 'sessionId': weidu.sessionId}
        json = {'recordId':weidu.recordId,'page': 1, 'count': 5}
        recordlist=requests.get(url=url,headers=headers,params=json)
        print(recordlist.json())

    #问诊聊天记录 findInquiry
    def test_04_findinquiry(self):
        url = weidu.host + '/health/doctor/inquiry/verify/v1/findInquiryDetailsList'
        headers = {'doctorId': str(weidu.doctorId), 'sessionId': weidu.sessionId}
        json = {'recordId': str(weidu.recordId), 'page': 1, 'count': 5}
        findinquiry=requests.get(url=url,headers=headers,params=json)
        print(findinquiry.json())

    #查询用户详情 user
    def test_05_user(self):
        url = weidu.host + '/health/doctor/inquiry/verify/v1/findUserInfo'
        headers = {'doctorId': str(weidu.doctorId), 'sessionId': weidu.sessionId}
        json = {'userId': str(weidu.userId)}
        user=requests.get(url=url,headers=headers,params=json)
        print(user.json())

    #结束问诊 endInquiry
    def test_06_endInquiry(self):
        url = weidu.host + '/health/doctor/inquiry/verify/v1/endInquiry'
        headers = {'doctorId': str(weidu.doctorId), 'sessionId': weidu.sessionId}
        json = {'recordId': weidu.recordId}
        endInquiry=requests.put(url=url,headers=headers,json=json)
        print(endInquiry.json())

#执行
if __name__ == '__main__':
    unittest.main()